{include file="public/header" /}

<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>{:lang('admin info')}
                        <!--<small>管理员信息设置</small>-->
                    </h5>
                </div>
                <div class="ibox-content">
                    <form method="get" class="form-horizontal" id="form1">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{:lang('admin name')}</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control"
                                       value="{$adminInfo.adminName}" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{:lang('admin role')}</label>
                            <div class="col-sm-10">
                                {if condition="$adminInfo.roleID eq 0"}
                                <input type="text" class="form-control"
                                       value="超级管理员" readonly>
                                {else/}
                                <input type="text" class="form-control"
                                       value="{$adminInfo.roleName}" readonly>
                                {/if}

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{:lang('admin avatar')}</label>
                            <div class="col-sm-10" onclick="GetUploadify(1,'','admin-admin_avatars','call_back');">
                                <img id="img_holder" src="{$adminInfo.adminAvatar|default='__ROOT__/static/stark.jpg'}"
                                     width="100" height="100">
                                <input name="adminAvatar" id="img_src" type="hidden"
                                       value="{$adminInfo.adminAvatar|default=''}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{:lang('admin phone')}</label>
                            <div class="col-sm-10">
                                <input name="adminPhone" type="text" class="form-control"
                                       value="{$adminInfo.adminPhone|default=''}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{:lang('admin email')}</label>
                            <div class="col-sm-10">
                                <input name="adminEmail" type="text" class="form-control"
                                       value="{$adminInfo.adminEmail|default=''}">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" onclick="doSubmit()">{:lang('edit')}</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer" /}
<script>
    function call_back(fileurl_tmp) {
        $("#img_src").val(fileurl_tmp);
        $("#img_holder").attr('src', fileurl_tmp);
    }

    function doSubmit() {
        $.ajax({
            url: "{:U('Admin/baseInfo')}",
            type: 'post',
            data: $('#form1').serialize(),
            dataType: 'JSON',
            success: function (data) {
                if (data.status == 1) {
                    layer.msg(data.msg);
                    setTimeout(function () {
                        location.reload();
                        $('#parentAdminAvatar', parent.document).attr('src', data.res)
                    }, 1000)
                } else {
                    layer.msg(data.msg);
                }
            }
        });
        return false;
    }
</script>
